/*
 * Copyright (c) 2014, S.F. Express Inc. All rights reserved.
 */
package org.jasig.cas.client.ext;

import org.jasig.cas.client.util.ReflectUtils;

/**
 * 描述：
 * 
 * <pre>
 * HISTORY
 * ****************************************************************************
 *  ID   DATE            PERSON          REASON
 *  1    2015年12月15日     014767          Create
 * ****************************************************************************
 * </pre>
 * 
 * @author 014767
 * @since 1.0
 */
public class CASClientHolder {

    private static ICASClient instance;
    private static String targetNode;

    public static void setCASClient(String casClientClass) {
        instance = ReflectUtils.newInstance(casClientClass);
    }

    public static ICASClient getInstance() {
        return instance;
    }

    public static String getTargetNode() {
        if (targetNode == null) {
            Node node = instance.getNode();
            if (node == null) {
                targetNode = "";
            } else {
                targetNode = "target=" + EncryptUtils.encode(node.toString());
            }
        }
        return targetNode;
    }
}
